#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
bool isValid(char* s)
{
    int len = strlen(s);
    char* tmp = malloc(sizeof(char) * (len + 1));
    int k = 0;
    for (int i = 0; i < len; ++i)
    {
        if (i == 0 || s[i] == '(' || s[i] == '[' || s[i] == '{')
        {
            tmp[k++] = s[i];
        }
        else
        {
            if ((tmp[k - 1] == '(' && s[i] == ')') ||
                (tmp[k - 1] == '[' && s[i] == ']') ||
                (tmp[k - 1] == '{' && s[i] == '}'))
                --k;
        }
    }
    free(tmp);
    if (k == 0)
        return true;
    else
        return false;
}
int main()
{
    char s[] = "()[]{}";
    bool a = isValid(s);
}